package com.engineering.elink.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.engineering.elink.co.BaseCo;
import com.engineering.elink.common.Pagination;
import com.engineering.elink.common.ResultType;
import com.engineering.elink.dao.NotifyMapper;
import com.engineering.elink.domain.Notify;
import com.engineering.elink.service.NotifyService;
import com.engineering.elink.util.MapConvert;

@Service
public class NotifyServiceImpl implements NotifyService {
	@Autowired
	private NotifyMapper NotifyMapper;

	@Override
	public Map<String, Object> getList(BaseCo co, String userId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("list", NotifyMapper.selectList(co,userId));
		map.put("Pagination", new Pagination(co, NotifyMapper.selectCount(userId)));
		return map;
	}

	@Override
	public int getUnreadCount(String userId) {
		return NotifyMapper.selectUnreadCount(userId);
	}

	@Override
	public Notify getInfo(int notifyId) {
		 NotifyMapper.updateReadStatusByNotifyId(notifyId);
		return NotifyMapper.selectInfo(notifyId);
	}

	@Override
	public int del(String notifyId, String userId) {
		return  NotifyMapper.del(notifyId,userId);
	}
	
	@Override
	public Map<String, Object> clearNotify(String userId) {
		return   MapConvert.getMap(ResultType.SUCCESS,NotifyMapper.clearNotify(userId));
	}
}
